<template>
    <div>
        <div>
            <van-nav-bar title="注册" left-text="返回" left-arrow @click="toHome" />
        </div>

        <!-- 注册组件 -->
        <registerCom v-if="types === '1'" :password1="password1" :email="email">
            <van-field v-model="password1" required type="password" label="确认密码" placeholder="请再次输入密码" />
            <van-field v-model="email" required type="email" label="电子邮件" placeholder="电子邮件地址" />
        </registerCom>

        <registerCom v-else></registerCom>

        <van-divider />

        <!-- 已有账号，立即登录 -->
        <div class="register-bottom">
            <p>已有账号？</p>
            <van-button block round :to="{ name: 'UserLogin' }">立即登录</van-button>
        </div>
    </div>
</template>

<script setup>
import registerCom from '@/components/RegisterCom.vue';
import router from '@/router';
import {  ref } from 'vue';
import { useRoute } from 'vue-router';

const registerRoute = useRoute()
let password1 = ref('')
let email = ref('')

let types = registerRoute.params.types


const toHome = () => {
    router.push({name: 'homePage'});
}

</script>

<style scoped lang="scss">
.icon-back {
    position: absolute;
    left: 2px;
    top: 15px
}

.register-bottom {
    width: 100vw;

    & button {
        width: 90vw;
        margin: 0 5vw;
    }

    & p {
        opacity: .5;
        text-align: center;
    }
}
</style>